package com.ITD.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

@Configuration
public class Knife4jConfig {
    @Bean(value = "dockerBean")
    public Docket dockerBean() {
        //首页信息
        ApiInfo apiInfo = new ApiInfoBuilder()
                .title("itd文档")
                .version("2.0")
                .termsOfServiceUrl("https://doc.xiaominfo.com/")
                .contact(new Contact("朱宏楷", "https://github.com/ITD-dev", "ITD@163.com"))
                .description("itd接口文档")
                .build();

        //指定使用Swagger2规范
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo)
                //分组名称
                .groupName("服务")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("com.ITD.controller"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }
}
